#ifndef __MAKE_MARKET__
#define __MAKE_MARKET__

#include <atomic>
#include "IUtility.h"
#include "IMakeMarket.h"
#include "IPacket.h"
#include "IThreadPoolManager.h"
#include "tinyxml.h"
#include "ISysResources.h"
#include "IContainer.h"


class CMakeMarket : public virtual IMakeMarket, public virtual IEmergency
{
INIT_CLASS_SINGLETON(CMakeMarket)
public:
	const bool Init(const void * pvdPara, char * pszMsgTxt, int iMsgTxtSize);
	const char * GetMonitorIdByStkCode(const char * pszStkCode, char ** szLbmNoSet, int &iLen);
	const char * GetMonitorLbmNoSetByMonitorId(const int iMonitorId);
	const void AddL3016302Info(IPacket * ptrPkt/*const char * pszResult*/);
	const void GetL3016302InfoByMonitorId(int iMonitorId, void * ptrVector);
	const void GetL3016302InfoByStkCode(const char * szStkCode, void * ptrVector);
    void ReleaseMemory_L3016302(void * ptrVector);
	const void AddL3010028Info(IPacket * ptrPkt);
	const void * GetL3010028Info(int iAssetId);
	const void AddL3016310Info(const char * pszResult); 
	const void GetL3016310Info(const char * szStkCode, void * ptrVector);
    void ReleaseMemory_L3016310(void * ptrVector);
	const void AddL3014026Info(IPacket * ptrPkt);
	const void * GetL3014026Info(const char * szStkCode);
    void ReleaseMemory_L3014026(void * ptrItem);
	const void AddL3010029Info(IPacket * ptrPkt);
	const void * GetL3010029Info(int iProjectId, int iPbuCls);
	const void AddMonitorTask(const char * pszQueueName, IPacket * ptrPkt);
	const void AddMonitorProcessTask(const char * pszTaskName, IPacket * ptrPkt);
    const bool ChkMonitorTaskStatus(const char * pszTaskName);
    const bool RegMonitorTaskStatus(const char * pszTaskName);
	const IPacket * GetMonitorProcessTask(const char * pszTaskName);
	const bool EmergencyFlg();
	const void SetEmergencyFlg(bool bEmergencyFlg);
	const char * EmergencyEventName();

private:
	shared_ptr<IStrFun> m_ptrStrFun;
	shared_ptr<ISysFun> m_ptrSysFun;
    shared_ptr<ILock> m_ptrMonitorInfoLock, m_ptrMonitorAssetInfoLock, m_ptrRiskRelationLock,
        m_ptrStkLock, m_ptrMonitorProcessTaskLock, m_ptrProjectLock;
	map<string, shared_ptr<vector<shared_ptr<IPacket>>>> m_mpInfo;
    shared_ptr<IKcbpLbmManager> m_ptrKcbpLbmManager;
    shared_ptr<IQueueOperation> m_ptrQueueOperation;
	atomic<bool> m_bEmergencyFlg;
	string m_strEmergencyEventObjectName;
	map<int, shared_ptr<ST_MONITOR_CONFIG>> m_mpMonitorConfig;
	map<string, shared_ptr<vector<shared_ptr<ST_MONITOR_INO>>>> m_mpMonitorInfoByStkCode;
	map<int, shared_ptr<vector<weak_ptr<ST_MONITOR_INO>>>> m_mpMonitorInfoByMonitorId;
	map<string, shared_ptr<vector<int>>> m_mpStkCodeMonitorId;
	map<int, shared_ptr<ST_ASSET_INFO>> m_mpAssetInfo;
	map<string, shared_ptr<ST_STK_INFO>> m_mpStkInfo;
	map<string, shared_ptr<ST_PROJECT_INFO>> m_mpProjectInfo;
	map<string, shared_ptr<vector<shared_ptr<ST_RISK_RELATION>>>> m_mpRiskRelation;
	map<string, IPacket *> m_mpMonitorProcessTask;
    map<string, int> m_mpMonitorTaskStatus;
};


#endif//__MAKE_MARKET__